home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / NextAnswers / UndoManager / UndoManager.h < prev    next >
Text File  |  1994-06-15  |  3KB  |  109 lines

  1. #import <appkit/appkit.h>
  2. //  Written by: Jeff Martin (jmartin@bozell.com)
  3. //  You may freely copy, distribute and reuse the code in this example.  
  4. //  Don't even talk to me about warranties.
  5.  
  6. @interface UndoManager : Object
  7. {
  8.     id    undoList;    // The list that holds undo records
  9.     id    redoList;    // The list that holds redo records
  10.     int    disabled;    // Whether the UndoManager is accepting events
  11.     BOOL    undoing;    // Whether the UndoManager is currently undoing
  12.     BOOL    redoing;    // Whether the UndoManager is currently redoing
  13.     BOOL    recordGrouping;    // Whether UndoRecords are being grouped
  14.     int    levelsOfUndo;    // How many levels of undo/redo to record
  15.  
  16.     id    target;        // Current target of registered undo messages
  17.     unsigned int    freeArgsMask;    // Stores which args to free
  18.     unsigned int    copyArgsMask;    // Make undo manager copy pointer args
  19.     id    delegateList;    // List of objects to be notified of UM changes
  20. }
  21.  
  22. // Format of an undo/redo record
  23. typedef struct UndoRecord {
  24.     marg_list args;
  25.     int freeArgsMask;
  26.     int argSize;
  27. } UndoRecord;
  28.  
  29. - init;
  30.  
  31. // Grouping multiple UndoRecords into an undo event
  32. - beginUndoRecordGrouping;
  33. - endUndoRecordGrouping;
  34.  
  35. // Disable/Reenable UndoManager to prevent events from being added to undo list
  36. - disableUndoRegistration;
  37. - reenableUndoRegistration;
  38.  
  39. // Setting the current target for events that are received
  40. - setUndoTarget:object;
  41.  
  42. // Setting the target or args of the next registered method to be freed when 
  43. //  they fall off the end of the undo/redo list or are executed
  44. - freeUndoTarget;
  45. - freeUndoArgs;
  46. - freeUndoArgAt:(int)pos;
  47.  
  48. // Setting the target or args of the next registered method to be freed when 
  49. //  they fall off the end of the undo/redo list
  50. - freeUndoTargetOnRecordDiscard;
  51. - freeUndoArgsOnRecordDiscard;
  52. - freeUndoArgOnRecordDiscardAt:(int)pos;
  53.  
  54. // Setting the target or args of the next registered method to be freed when 
  55. //  they are executed
  56. - freeUndoTargetOnRecordExecute;
  57. - freeUndoArgsOnRecordExecute;
  58. - freeUndoArgOnRecordExecuteAt:(int)pos;
  59.  
  60. // Make UndoManager copy arguments(like objects or strings) for convenience
  61. - copyUndoArgs;
  62. - copyUndoArgAt:(int)pos;
  63.  
  64. // Make UndoManager copy arguments and free them when record is discarded
  65. - copyUndoArgsFreeOnDiscard;
  66. - copyUndoArgFreeOnDiscardAt:(int)pos;
  67.  
  68. // Make UndoManager copy arguments and free them when record is executed
  69. - copyUndoArgsFreeOnExecute;
  70. - copyUndoArgFreeOnExecuteAt:(int)pos;
  71.  
  72. // Copies the pointer args in undoRecord as requested by copyArgsMask
  73. - copyUndoArgsForRecord:(UndoRecord *)undoRecord;
  74.  
  75. // Overridden to capture undo/redo messages to be added to current record
  76. - forward:(SEL)aSelector :(marg_list)argFrame;
  77.  
  78. // Removes a record from the undo/redo list and dispatches the messages in it.
  79. - undo:sender;
  80. - redo:sender;
  81.  
  82. // Query and set the maximum length of the undo/redo list
  83. - (int)levelsOfUndo;
  84. - setLevelsOfUndo:(int)value;
  85.  
  86. // These methods add and remove objects that are to receive undo notification.
  87. - addUndoDelegate:object;
  88. - removeUndoDelegate:object;
  89. - sendNotification:(SEL)action;
  90.  
  91. // Used internally to free the space used for an undo/redo groups and records
  92. - discardRecordGroup:recordGroup;
  93. - executeRecordGroup:recordGroup;
  94. - freeUndoRecord:(UndoRecord *)undoRecord withFreeMask:(int)mask;
  95.  
  96. // Remove and Free all records currently stored in the UndoManager 
  97. - emptyUndoManager;
  98.  
  99. // Free space used by UndoManager
  100. - free;
  101.  
  102. @end
  103.  
  104. extern id undoManager;
  105.  
  106. @protocol UndoDelegate
  107. - undoManagerWillUndo:sender;
  108. - undoManagerDidUndo:sender;
  109. @end